This is probably the simplest compete OSAX programming example there is. It's so simple because it has neither input nor ouyput parameters, and so avoids all the messy AppleEvents programming usually assoaciated with OSAXen. But it is complete, and includes the CW9 project and what I think are minimal resources for such an OSAX.
The project is a 68k code resource. It would be possible to create a PowerPC or fat code resource, but this would be a lot more work and for such a simple OSAX there would be little benefit in doing so. Most OSAXen are so simple that they would not benefit much from being recompiled for PowerPC (and in most cases if you need PowerPC performance and can program in C then why are you considering doing it within AppleScript ?)
For such a simple project most compiler options either do not matter, depend on the code in question or are up to the programmer. The only ones that are generally fixed are the '68k Project' options, which should look something like this:
Note that as well as the file creator 'ascr
', file type 'osax
'
and resource type 'osax
' you need to precisely specify the resource name,
as this is how AppleScript knows which resource corresponds to which AppleEvent. The
syntax is 'AEVTxxxxyyyy
', where 'xxxx
' is the Event Class* and
'yyyy
' is the Event ID. The resource ID is not important and need only
be unique and at least 128 (as IDs below this are reserved by Apple).
* note that in a previous version of these notes, in the sample project and the copy of Switch Keyboard distributed with the sample project, I wrongly used the Suite ID in place of the Event Class. Thanks to Ben Richardson for alerting me to this.
Apart from the source the only other file in the project
is a file or resources, which I've DeRezed and included below. In addition to the
obligitary 'aete
' resource there's a 'STR
' string ID -16397,
which is presented to the user if he/she double-clicks on the resource, and a set of 'vers
' resources, to help indentify the OSAX. I found it easiest to create
and edit these in ResEdit, using Yuji Hachiya's Aete Editor to create the aete resource.
(Note: some of the following is non-ASCII, and so may produce unpredictable results on some browsers, especially non-Mac browsers. If in doubt save the source and view that, or just hack into JWB utilties with ResEdit to view the resources themselves.)
resource 'vers' (1, purgeable) { 0x1, 0x1, release, 0x0, verUS, "1.0", "1.0 © John Blackburne <johnb@tempest.net" ".hk>, 14 Aug 1995" }; resource 'vers' (2) { 0x1, 0x0, release, 0x0, verUS, "1.0", "Another John’s Suite" }; resource 'STR ' (-16397) { "This document cannot be opened or printe" "d. It extends the functionality of Apple" "Script™ and should be placed in the Scri" "pting Additions folder found in the Exte" "nsions folder of your System Folder." }; resource 'aete' (0, "switch keyboard") { 0x1, 0x0, english, roman, { /* array Suites: 1 elements */ /* [1] */ "Another John’s Suite", "® 1995 John Blackburne, johnb@tempest.ne" "t.hk", 'JWB_', 1, 1, { /* array Events: 1 elements */ /* [1] */ "switch keyboard", "Switch to next keyboard within current s" "cript", 'misc', 'SKbd', noReply, "", replyRequired, singleItem, notEnumerated, tightBindingFunction, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, verbEvent, reserved, reserved, reserved, noParams, "", directParamOptional, singleItem, notEnumerated, changesState, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, reserved, { /* array OtherParams: 0 elements */ } }, { /* array Classes: 0 elements */ }, { /* array ComparisonOps: 0 elements */ }, { /* array Enumerations: 0 elements */ } } };
Intro * User Docs * Source * Project Notes
© John Blackburne, johnb@hk.super.net, 9th June 1996